<!DOCTYPE html>
<#assign dicSelect = JspTaglibs["http://www.casic304.cn/dicSelect"]/>
<#assign f = JspTaglibs["http://www.casic304.cn/f"] />
<#assign SourceDept = JspTaglibs["http://www.casic304.cn/SourceDept"]/>
<head>
    <meta charset="utf-8">
    <title>质量信得过班组管理信息列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/style/qbdms.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
</head>
<body class="listBody">
<div class="qbdms-list">
    <div class="layui-table-view-body">
        <table id="wQbdTrustTeamTable" lay-filter="wQbdTrustTeamTable"></table>
    </div>
</div>
<!-- 列表头部工具栏 -->
<script type="text/html" id="wQbdTrustTeamHeaderToolsBar">
    <div class="ccpui-enterSel">
        <div class="layui-btn-container">
            <@f.a alias="xzan_zlxdgbz302" css="layui-btn layui-btn-sm fillBtn" event="add">
                <span>新增</span>
            </@f.a>
            <@f.a alias="scan_zlxdgbz302" css="layui-btn layui-btn-sm" event="delete">
                <span>删除</span>
            </@f.a>
                <span class="layui-btn layui-btn-sm" lay-event="export">导出</span>
        </div>
        <form class="layui-form" action="" lay-filter="wQbdTrustTeamQueryForm" >
            <div class="layui-form-body selch">
                <div class="table-top-filter layui-row">

                    <div class="qbdms-listForm">
                        <label class="layui-form-label">班组名称</label>
                        <div class="layui-input-block">
                        <input type="text" class="layui-input filter-value" name="Q_teamname_SL" placeholder="请输入"/>
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">申报类别</label>
                        <div class="layui-input-block">
                        <@dicSelect.dic name="Q_declares_SL" css="layui-input filter-value" search=true nodeKey="bzsblb" />
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                    <label class="layui-form-label">开始时间</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input start_time1 filter-value" name="Q_beginCreateTime_DL"
                               readonly  placeholder="请输入"/>
                    </div>
                </div>
                <div class="qbdms-listForm">
                    <label class="layui-form-label">结束时间</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input end_time1 filter-value" name="Q_endCreateTime_DE"
                               readonly   placeholder="请输入"/>
                    </div>
                </div>
                </div>
                <div class="selchBtn">
                    <a class="layui-btn layui-btn-sm fillBtn" lay-event="query">
                        <span>查询</span>
                    </a>
                    <div class="layui-btn-group">
                        <button type="button" class="layui-btn layui-btn-sm" lay-event="clears" style="width: 28px;font-size: 12px;padding: 0">
                            <i class="iconfont data-iconcommon_refresh"></i>
                        </button>
                        <button type="button" class="layui-btn layui-btn-sm screenParent" lay-event="screen" style="width: 28px;font-size: 12px;padding: 0">
                            <i class="iconfont data-iconcommon_downarrow screen"></i>
                        </button>
                    </div>
                </div>
            </div>
        </form>
    </div>

</script>
<!-- 右侧工具栏 -->
<script type="text/html" id="wQbdTrustTeamRightToolsBar">
    {{# if('${currentUserId}'==d.createBy && d.allowEdit){}}
    <@f.a alias="bjan_zlxdgbz302" css="RightBtn" event="edit">编辑</@f.a>
    {{#  } }}
    <a class="RightBtn" lay-event="particulars">详情</a>
    {{# if('${currentUserId}'==d.createBy && d.allowDel){}}
    <@f.a alias="scan_zlxdgbz302" css="RightBtn" event="del">删除</@f.a>
    {{#  } }}
</script>
<script src="${ctx}/qbdmsStatic/public/configFile.js"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>
    //一般直接写在一个js文件中
    layui.config({
        base: serverPath.qbdmsPath + staticPath.qbdmsPath //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','table','laydate', 'form', 'common','publicMethods','jquery','layer','propsHandle'], function () {
        var laydate = layui.laydate;
        var table = layui.table;
        var form = layui.form;
        var common = layui.common;
        var publicMethods = layui.publicMethods;
        var $ = layui.jquery;
        var layer = layui.layer;
        var propsHandle = layui.propsHandle;
        var defProps = {
                //viewMould: 'form/formDef/view/formDesign/moulds/', // 组件模块 存放文件 *****
                viewMould: 'moulds/', // 组件模块 存放文件 *****
                selectorBtn: '.selectorBtn'
            },
            temQuery = new propsHandle();  // 实例化模板功能部分
        temQuery.initTem({
            selectorBtn: defProps.selectorBtn,
            selectorTemPath: setter.views + defProps.viewMould
        });
        common.tableSort('wQbdTrustTeamTable');



        var tableH=publicMethods.tabHeight();
        var cols = '${cols}';
        var commonCols = [
            {type: 'checkbox', fixed: 'left'}
            ,{field: 'sn', type: 'numbers', title: '序号', fixed: 'left'}
            ,{field: 'teamname', title: '班组名称',sort:false, sortname: 'teamname',minWidth:'150'}
            ,{field: 'teamcount', title: '班组人数',sort:false, sortname: 'teamcount',minWidth:'100'}
            ,{field: 'teamdept', title: '单位',sort:false, sortname: 'teamdept',minWidth:'120'}
            ,{field: 'declares', title: '申报类别',sort:false, sortname: 'declares',minWidth:'100'}
            ,{field: 'teamLeaderName', title: '组长',sort:false, sortname: 'teamLeaderName',minWidth:'180'}
            ,{field: 'flowStatusStr', title: '状态',sort:false, sortname: 'flowStatusStr',minWidth:'180'}
        ];

        var hideCols = [
            ,{field: 'numbers', title: '序号',sort:false, sortname: 'numbers',hide: true,minWidth:'80'}
            ,{field: 'createTarget', title: '创建目标',sort:false, sortname: 'createTarget',hide: true,minWidth:'80'}
            ,{field: 'createPlan', title: '创建计划',sort:false, sortname: 'createPlan',hide: true,minWidth:'80'}
            ,{field: 'createTime', title: '创建时间',sort:false, sortname: 'createTime',hide: true,minWidth:'80'}


        ];

        var manageCols =[{
            fixed: 'right',
            minWidth:'200',
            title: '管理',
            toolbar: '#wQbdTrustTeamRightToolsBar'
        }];
        var totalCols = [];
        totalCols = totalCols.concat(commonCols).concat(hideCols).concat(manageCols);
        //第一个实例
        table.render({
            elem: '#wQbdTrustTeamTable'
            ,height:tableH
            ,url: serverPath.qbdmsPath + '/qbdms/wQbdTrustTeam/list'
            ,page: publicMethods.pageFun()
            , limit: 20
            ,defaultToolbar: ['']
            ,toolbar: '#wQbdTrustTeamHeaderToolsBar'
            ,method: 'post'
            ,autoSort: false //是否排序
            ,cols: [cols ? JSON.parse(cols) : totalCols],done:function () {
                common.tableSelectCon('.ccpui-enterSel .layui-form input','a[lay-event=query]','.ccpui-enterSel');
            }
            ,parseData: function(res){ //res 即为原始返回的数据
                common.parseDataList(res,['money','teampeople','devote','remark','files']);
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.count, //解析数据长度
                    "data": res.data //解析数据列表
                };
            }
        });
        
        dateReflash()
        //list页面初始化展开按钮tips展示（展开按钮类名）
        publicMethods.tipsAuto('.screen')
        //筛选条件初始化（页面表格的Id，是否初始化（true、false））
        common.initScreenTop('wQbdTrustTeamTable',true);

        function dateReflash() {
            publicMethods.reflashDate({startName:'.start_time1',endName:'.end_time1'});
        }

        function reflashQuery(isClear) {
            common.tableConditionRender("wQbdTrustTeamTable","wQbdTrustTeamQueryForm",{where:{}},isClear);
        }

        table.on('toolbar(wQbdTrustTeamTable)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data;
            var _this = this;
            switch (obj.event) {
                case 'add':
                    window.location.href = serverPath.qbdmsPath + "/qbdms/wQbdTrustTeam/view/add";
                    break;

                case 'delete':
                    var array = "";
                    for (var i = 0; i < data.length; i++) {
                        array+=data[i].id+",";
                    }
                    delFun(data,array);
                    break;
                case 'export':
                    function open(url , param){
                        var curUrl = url;
                        layer.open({
                            type: 2,
                            area: ['700px', '520px'],
                            title: ['自定义导出', 'font-size:14px;'],
                            content: serverPath.qbdmsPath + '/qbdms/wQbdTrustTeam/view/export',
                            btnAlign: 'c',
                            skin: 'qbdms-layerFormBtn',
                            btn: ['确定', '取消'],
                            yes: function(index, layero){
                                url = curUrl;
                                var iframeWin = window["layui-layer-iframe" + index];
                                var data = iframeWin.getData();
                                if(data){
                                    url = url + "?data=" + JSON.stringify(data) + param;
                                    window.location.href = encodeURI(url)
                                }
                            }
                        });
                    }

                    if (data.length == 0) {
                        layer.confirm(publicMethods.confirmStyle('还没有选择，是否导出全部?'),{title: false,skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            var url = serverPath.qbdmsPath + '/qbdms/wQbdTrustTeam/exportData';
                            var param = "";
                            $("form[lay-filter='wQbdTrustTeamQueryForm']").find(".filter-value").each(function(i,value) {
                                param += "&"+this.name+"="+this.value
                            });
                            open(url , param);
                        });
                    } else {
                        layer.confirm(publicMethods.confirmStyle('确定导出吗?'),{title: false,skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            var ids = [];
                            for (var i = 0; i < data.length; i++) {
                                ids.push(data[i].id);
                            }
                            var url = serverPath.qbdmsPath + '/qbdms/wQbdTrustTeam/exportData';
                            open(url , "&id="+ids);
                        });
                    }
                    break;
                case "import":
                    common.importInit('wQbdTrustTeamTable',"/qbdms/wQbdTrustTeam/importData",true,"/importTemplates/质量信得过班组.xlsx");
                    dateReflash();
                    break;
                case "query":
                    reflashQuery(false);
                    dateReflash();
                    break;
                case "report":
                    var array = "";
                    for (var i = 0; i < data.length; i++) {
                        array += data[i].id + ",";
                    }
                    reportFun(data, array);
                    dateReflash();
                    break;
                case "screen":
                    common.initScreenTop('wQbdTrustTeamTable');
                    dateReflash();
                    form.render();
                    break;
                case "clears":
                    reflashQuery(true);
                    dateReflash();
                    break;

            };
        });

        table.on('tool(wQbdTrustTeamTable)', function(obj) {
            var data = obj.data, //获得当前行数据
                layEvent = obj.event; //获得 lay-event 对应的值
            switch(layEvent){
                case "edit":
                    window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdTrustTeam/view/add?id='+data.id;
                    break;
                case "particulars":
                    window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdTrustTeam/view/particulars?id='+data.id;
                    break;
                case "del":
                    delFun(data,data.id);
                    break;
                case "evaluate":
                    if (data.evaluatestatus === "待评定") {
                        layer.open({
                            title: false,
                            skin:'confirm-class',
                            btn: ['通过', '不通过', '取消'],
                            content: publicMethods.confirmStyle("请确认评定结果!"),
                            yes: function (index, layero) {
                                var nowData = {
                                    "id": data.id,
                                    "evaluatestatus": "通过"
                                };
                                evaluate(nowData);
                                layer.close(index);
                            }
                            , btn2: function (index, layero) {
                                var nowData = {
                                    "id": data.id,
                                    "evaluatestatus": "未通过"
                                };
                                evaluate(nowData);
                                layer.close(index);
                            }
                        });
                    } else {
                        layer.alert('该数据不允许评定!');
                    }
                    dateReflash();
                    break;
            }
        });

        function delFun(data,id) {
            if (data.length === 0) {
                layer.confirm(publicMethods.confirmStyle("请先选择一行数据!"),{title: false,skin: 'confirm-class'});
            } else {
                layer.confirm(publicMethods.confirmStyle('确定删除当前数据吗?'),{title: false,skin: 'confirm-class'},function (index) {
                    layer.close(index);
                    $.ajax({
                        url: serverPath.qbdmsPath + "/qbdms/wQbdTrustTeam/del",
                        type: "post",
                        data: {id:id},
                        dataType: 'json',
                        success: function (data) {
                            layer.confirm(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            layer.confirm(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        }
                    })
                })
            }
        }

        function delFun(data,id) {
            if (data.length === 0) {
                layer.confirm(publicMethods.confirmStyle("请先选择一行数据!"),{title: false,skin: 'confirm-class'});
            } else {
                layer.confirm(publicMethods.confirmStyle('确定删除当前数据吗?'),{title: false,skin: 'confirm-class'},function (index) {
                    layer.close(index);
                    $.ajax({
                        url: serverPath.qbdmsPath + "/qbdms/wQbdTrustTeam/del",
                        type: "post",
                        data: {id:id},
                        dataType: 'json',
                        success: function (data) {
                            layer.confirm(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            layer.confirm(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        }
                    })
                })
            }
        }

        function reportFun(data, id) {
            if (data.length === 0) {
                layer.msg("请先选择一行数据!");
            } else {
                layer.confirm(publicMethods.confirmStyle('确定上报当前数据吗?'),{title: false,skin: 'confirm-class'},function (index) {
                    $.ajax({
                        url: serverPath.qbdmsPath + "/qbdms/wQbdTrustTeam/reportList",
                        type: "POST",
                        data: {id: id},
                        dataType: "json",
                        success: function (data) {
                            layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        }, error: function (XMLHttpRequest, textStatus, errorThrown) {
                            layer.alert("数据上报失败！" + XMLHttpRequest.status);
                        }
                    })
                });
            }
        }

        function evaluate(nowData) {
            $.ajax({
                url: "${ctx}/qbdms/wQbdTrustTeam/evaluate",
                type: "post",
                dataType: 'json',
                contentType: 'application/json',
                data: JSON.stringify(nowData),
                success: function (data) {
                    layer.alert(data.msg);
                    //执行重载
                    reflashQuery(false);
                    dateReflash();
                    return false;
                }
            })
        }


        window.Initialization = function () {
            dateReflash();
        };
        /*刷新时间控件*/
        dateReflash();
        common.tableSort("wQbdTrustTeamTable");
    });
</script>
</body>
</html>